/*
 * @Author: pengtianrui 2276608413@qq.com
 * @Date: 2024-08-22 17:51:39
 * @LastEditors: pengtianrui 2276608413@qq.com
 * @LastEditTime: 2024-08-23 09:26:35
 * @FilePath: \SGFEM\DataStructure\FEM\Property\src\PBARData.cpp
 */
#include "DataStructure/Input/Property/PBARData.h"

#include "DataStructure/Common/Validation.h"

bool SG::DataStructure::FEM::operator== (const PBARData& a, const PBARData& b)
{
    if (a.m_id != b.m_id)
    {
        return false;
    }
    if (a.m_mId != b.m_mId)
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_A, b.m_A))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_I1, b.m_I1))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_I2, b.m_I2))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_J, b.m_J))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_NSM, b.m_NSM))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_FE, b.m_FE))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_C1, b.m_C1))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_C2, b.m_C2))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_D1, b.m_D1))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_D2, b.m_D2))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_E1, b.m_E1))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_E2, b.m_E2))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_F1, b.m_F1))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_F2, b.m_F2))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_K1, b.m_K1))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_K2, b.m_K2))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_I12, b.m_I12))
    {
        return false;
    }
    if (a.m_domainId != b.m_domainId)
    {
        return false;
    }
    return true;
}

void SG::DataStructure::FEM::PBARData::SetStressPoints (const std::vector<double>& v)
{
    if (v.size () < 8)
    {
        std::cout << "can't save stress point\n";
        return;
    }

    m_C1 = v[0];
    m_C2 = v[1];
    m_D1 = v[2];
    m_D2 = v[3];
    m_E1 = v[4];
    m_E2 = v[5];
    m_F1 = v[6];
    m_F2 = v[7];
}